package com.bio.action.right;

import java.util.List;

import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.bio.action.AbstractAction;
import com.bio.entity.right.Menu;
import com.bio.service.right.MenuService;

@Namespace("/menu")
@Results( {
		@Result(name = "list", location = "/WEB-INF/views/right/listFirstClassMenus.jsp", type = "dispatcher"),
		@Result(name = "tolist", location = "menu!list", type = "redirect"),
		@Result(name = "edit", location = "/WEB-INF/views/right/editMenu.jsp", type = "dispatcher"),
		@Result(name = "add", location = "/WEB-INF/views/right/addMenu.jsp", type = "dispatcher")
		})
public class MenuAction extends AbstractAction<Menu, MenuService> {

	private static final long serialVersionUID = 7254046709888531177L;

	public MenuAction(MenuService service) {
		super(service);
	}

	private Long superiorId;
	
	private List<Menu> allMenus;
	
	public String list(){
		this.pager = this.service.findMenusBySuperior(null);
		return "list";
	}
	
	public String listLower(){
		this.pager = this.service.findMenusBySuperior(superiorId);
		return "list";
	}

	public List<Menu> getAllMenus() {
		return allMenus;
	}

	public void setAllMenus(List<Menu> allMenus) {
		this.allMenus = allMenus;
	}

	public Long getSuperiorId() {
		return superiorId;
	}

	public void setSuperiorId(Long superiorId) {
		this.superiorId = superiorId;
	}
	
}
